      PROGRAM CGNHLP
      IMPLICIT NONE
      INTEGER MARG, NARG
      PARAMETER (MARG=5)
      CHARACTER*40 FILE
      CHARACTER*50 ARG(MARG)
      CHARACTER*79 CMDLIN
      LOGICAL GO
      DATA GO / .TRUE. /
C
      OPEN( 5, FILE='*' )
      OPEN( 6, FILE='*' )
      CALL ARGS( CMDLIN )
      CALL BREAKU( CMDLIN, MARG, NARG, ARG )
      IF( NARG .LE. 0 ) THEN
         WRITE(5,*) 'Enter name of the .DOC file (without extension)'
         READ(5,'(A)' ) ARG(1)
      ELSEIF( ARG(1) .EQ. '?' ) THEN
         CALL HELP
         GO = .FALSE.
      ELSE
         FILE = ARG(1)
      ENDIF
      IF( GO ) THEN
         CALL DOIT( FILE )
      ENDIF
      CLOSE( 6 )
      CLOSE( 5 )
      STOP
      END
C--------------------------------------------------------------------
      SUBROUTINE DOIT( FILE )
      IMPLICIT NONE
      INTEGER BLANK, L, LASTC
      CHARACTER*(*) FILE
      CHARACTER*1 Q
      CHARACTER*80 CARD
C
      BLANK = INDEX( FILE, ' ' ) - 1
      OPEN( 1, FILE=FILE(1:BLANK)//'.DOC', STATUS='OLD' )
      OPEN( 2, FILE='HELP.C', STATUS='NEW' )
      Q = ''''
      WRITE( 2, '(A)' ) 'int help( )'
      WRITE( 2, '(A)' ) '{ '
      DO WHILE( .TRUE. )
         READ( 1, '(A)', END=7000 ) CARD
         L = LASTC( CARD )
         IF( L .LE. 0 ) THEN
            L = 1
         ENDIF
         IF( L .LE. 40 ) THEN
            WRITE( 2, '(A,A,A)' ) '   printf("', 
     +      CARD(1:L), '  \n " ) ; '
         ELSE
            WRITE( 2, '(A,A,A)' ) '   printf("',
     +      CARD(1:40), '" ) ; ' 
            WRITE( 2, '(A,A,A)' ) '   printf("', 
     +      CARD(41:L), ' \n " ) ; '
         ENDIF
      END DO
 7000 WRITE( 2, '(A)' ) '   return( 0 ) ; '
      WRITE( 2, '(A)' ) '} '
      CLOSE( 2 )
      CLOSE( 1 )
      RETURN
      END
